#include <bits/stdc++.h>
#define int long long
using namespace std;
int T,M,n,a[3001];
signed main()
{
	freopen("moon.in","r",stdin);
	freopen("moon.out","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>T>>M;
	a[0]=1;
	for(int i=1;i<=3000;i+=2)
		for(int j=3000;j>=i;j--)
			a[j]=(a[j]+a[j-i])%M;
	while(T--)
	{
		cin>>n;
		cout<<a[n]<<'\n';
	}
	return 0;
}
